home *** CD-ROM | disk | FTP | other *** search
-
- #include <process.h>
- #include <stdio.h>
- #include <string.h>
- #include <stdlib.h>
- #include <glib.h>
- #include <strlib.h>
- #include "land.h"
-
- /* #include "..\lib.h" */
-
- void dsetmsg(int com, int sw)
- {
- char hmsg1[80], hmsg2[80];
- int col;
-
- hmsg1[0] = '\0'; hmsg2[0] = '\0';
-
- if (com == 1) {
- strcpy(hmsg1, "ドライブ0から作業領域へデータを読み込みます。");
- strcpy(hmsg2, "作業領域を選択してください。");
- }
-
- if (com == 2) {
- strcpy(hmsg1, "ドライブ1から作業領域へデータを読み込みます。");
- strcpy(hmsg2, "作業領域を選択してください。");
- }
-
- if (com == 3) {
- strcpy(hmsg1, "ドライブ2から作業領域へデータを読み込みます。");
- strcpy(hmsg2, "作業領域を選択してください。");
- }
-
- if (com == 4) {
- strcpy(hmsg1, "ドライブ3から作業領域へデータを読み込みます。");
- strcpy(hmsg2, "作業領域を選択してください。");
- }
-
- if (com == 6) {
- strcpy(hmsg1, "メイン・メニューにもどります。");
- }
-
- if (sw == 0) col = col7;
- else col = col0;
-
- msgset(96, 255, hmsg1, col);
- msgset(96, 275, hmsg2, col);
- }
-
-
- void migiya(int x, int y, int col)
- {
- int bcl[16];
-
- bcl[0] = col;
- line(x, y+4, x+29, y+19, PSET, col, 2, 0xffff);
- line(x+29,y, x+29, y+23, PSET, col, 0, 0xffff);
- line(x+29,y, x+39, y+12, PSET, col, 0, 0xffff);
- line(x+29,y+23,x+39, y+12, PSET, col, 0, 0xffff);
- paint(x+30,y+12, 1, col, 1, bcl);
- }
-
- void recogmsg(int x, int y, int col)
- {
- if (col < 0) {
- line(x-2, y-2, x+33, y+18, PSET, col15, 1, 0xffff);
- line(x-1, y-1, x+32, y+17, PSET, col0, 2, 0xffff);
- msgset(x, y, "確認", col15);
- } else {
- line(x-2, y-2, x+33, y+18, PSET, col, 1, 0xffff);
- line(x-1, y-1, x+32, y+17, PSET, col7, 2, 0xffff);
- msgset( x, y, "確認", col);
- }
- }
-
- void escmsg(int x, int y, int col)
- {
- if (col < 0) {
- line(x-2, y-2, x+33, y+18, PSET, col15, 1, 0xffff);
- line(x-1, y-1, x+32, y+17, PSET, col0, 2, 0xffff);
- msgset(x, y, "中止", col15);
- } else {
- line(x-2, y-2, x+33, y+18, PSET, col, 1, 0xffff);
- line(x-1, y-1, x+32, y+17, PSET, col7, 2, 0xffff);
- msgset( x, y, "中止", col);
- }
- }
-
- /* return( ok = 0, no = -1) , if (sw == 0) recog only */
- int recogin(int x, int y, int sw)
- {
- int mx, my;
-
- recogmsg(x, y, col0);
- if (sw != 0) escmsg(x+40, y, col0);
- while (1) {
- while ((MOS_rdpos(&mx, &my) & 0x01) == 0);
- if (xychk(mx, my,x,y, x+33, y+18) == 1) {
- recogmsg(x, y, -1);
- while((MOS_rdpos(&mx, &my) & 0x01) == 1);
- if (xychk(mx, my, x, y, x+33, y+18) == 0) {
- recogmsg(x, y, col0);
- continue;
- } else {
- return(0);
- }
- }
- if ((sw != 0) && (xychk(mx, my,x+40, y, x+73, y+18) == 1)) {
- escmsg(x+40, y, -1);
- while((MOS_rdpos(&mx, &my) & 0x01) == 1);
- if (xychk(mx, my, x+40, y, x+73, y+18) == 0) {
- escmsg(x+40, y, col0);
- continue;
- } else {
- return(-1);
- }
- }
- }
- }
-
- /* return( non = 0, rec = 1, esc = -1;) , if (sw == 0) recog only */
- int recogin2(int mx, int my, int x, int y, int sw)
- {
- if (xychk(mx, my,x,y, x+33, y+18) == 1) {
- recogmsg(x, y, -1);
- while((MOS_rdpos(&mx, &my) & 0x01) == 1);
- if (xychk(mx, my, x, y, x+33, y+18) == 0) {
- recogmsg(x, y, col0);
- return(0); /* continue; */
- } else {
- return(1); /* rec */
- }
- }
- if ((sw != 0) && (xychk(mx, my,x+40, y, x+73, y+18) == 1)) {
- escmsg(x+40, y, -1);
- while((MOS_rdpos(&mx, &my) & 0x01) == 1);
- if (xychk(mx, my, x+40, y, x+73, y+18) == 0) {
- escmsg(x+40, y, col0);
- return(0); /* continue; */
- } else {
- return(-1); /*esc */
- }
- }
- return(0);
- }
-
-
- void wareaerr(int warea)
- {
- char msg[80];
-
- helpcls( 80, 230, 560, 300);
- sprintf( msg, "作業領域 %d にエラーが発生しました。", warea);
- msgset(96, 255, msg, col10);
- msgset(96, 275, "確認ボタンを押してください。", col10);
- recogin( 435, 275, 0);
- return;
- }
-
- void drverr(int drv)
- {
- char msg[80];
-
- helpcls( 80, 230, 560, 300);
- sprintf( msg, "ドライブ%2d にエラーが発生しました。", drv);
- msgset(96, 255, msg, col10);
- msgset(96, 275, "確認ボタンを押してください。", col10);
- recogin( 435, 275, 0);
- return;
- }
-
-
- /* return: normal = 0; error = -1; */
- int headblkpri(unsigned char headblk[], int drv)
- {
- char msg1[80];
- char msg2[80];
- int secnum;
- char wwS[80], wS[80], wS2[80], satS[10], sensorS[10];
- int x,y, vol, nvol;
-
- x = 60; y = 65;
-
- helpcls( x, y, x+390, y+120); /* clear head print area */
-
- strmid(wS, headblk, 69, 6);
- if (strcmp(wS, "RESTEC") != 0) {
- helpcls( 80, 230, 560, 300);
- sprintf( msg1, "ドライブ%2d は LANDSAT/MOS ディスクではありません。", drv);
- msgset(96, 255, msg1, col10);
- msgset(96, 275, "確認ボタンを押してください。", col10);
- recogin( 435, 275, 0);
- return(-1);
- }
- strmid(wwS, headblk, 9, 4);
- strmid(wS, headblk, 25, 4);
- if ((atoi(wwS) != 1) || (atoi(wS) != 1)) {
- helpcls( 80, 230, 560, 300);
- sprintf( msg1, "この LANDSAT/MOS ディスクは間引き率が1ではありません。", drv);
- msgset(96, 255, msg1, col10);
- msgset(96, 275, "確認ボタンを押してください。", col10);
- recogin( 435, 275, 0);
- return(-1);
- }
-
- strmid(wS, headblk, 140, 1);
- if (strcmp(wS, "M") == 0) { strcpy(satS, "LANDSAT"); strcpy(sensorS, "MSS"); }
- if (strcmp(wS, "T") == 0) { strcpy(satS, "LANDSAT"); strcpy(sensorS, "TM"); }
- if (strcmp(wS, "E") == 0) { strcpy(satS, "MOS"); strcpy(sensorS, "MESSR"); }
- if (strcmp(wS, "V") == 0) { strcpy(satS, "MOS"); strcpy(sensorS, "VTIR"); }
-
- nvol = atoi(strmid(wS, headblk, 217, 4)); if (nvol == 0) nvol = 1;
- vol = atoi(strmid(wS, headblk, 221, 4)); if (vol == 0) vol = 1;
-
- sprintf(wwS, "%s-%s %s VOL%d/%d", satS, strmid(wS, headblk, 191, 1), sensorS, vol, nvol);
- msgset2(x+8, y+25, wwS, col0);
- sprintf(wwS, "LINE (START,END,INT) ... %s %s", strmid(wS, headblk, 1, 4), strmid(wS2, headblk, 5, 8));
- msgset2(x+8, y+35, wwS, col0);
- sprintf(wwS, "LINES ................... %s", strmid(wS, headblk, 13, 4));
- msgset2(x+8, y+45, wwS, col0);
- sprintf(wwS, "PIXEL (START,END,INT) ... %s %s", strmid(wS, headblk, 17, 4), strmid(wS2, headblk, 21, 8));
- msgset2(x+8, y+55, wwS, col0);
- sprintf(wwS, "PIXELS ................... %s", strmid(wS, headblk, 29, 4));
- msgset2(x+8, y+65, wwS, col0);
- sprintf(wwS, "%s", strmid(wS, headblk, 89, 8));
- msgset2(x+8, y+75, wwS, col0);
- sprintf(wwS, "%s", strmid(wS, headblk, 97, 43));
- msgset2(x+8, y+85, wwS, col0);
- sprintf(wwS, "%s", strmid(wS, headblk, 140, 36));
- msgset2(x+8, y+95, wwS, col0);
- sprintf(wwS, "%s", strmid(wS, headblk, 176, 29));
- msgset2(x+8,y+105, wwS, col0);
- return(0);
- }
- /* input vol = 0:non select, > 0:select; return 0 == no error, -10 == error */
- int volchg(int vol, int drv, unsigned char headblk[])
- {
- char msg[80];
- int devno, ret, ercnt;
- unsigned mode1, mode2;
- int cylno, hedno, secno, seccnt, secnum;
-
- do {
- helpcls( 80, 230, 560, 300);
- if (vol == 0) sprintf( msg, "ドライブ %d にデータ・ディスクをセットしてから", drv);
- else sprintf( msg, "ドライブ %d にデータ・ディスク Volume %d をセットしてから", drv, vol);
- msgset(96, 255, msg, col0);
- msgset(96, 275, "確認ボタンを押してください。", col0);
- if (recogin( 435, 275, 1) != 0) return(-1);
-
- devno = 0x0020 | drv; /* 1MB floppy */
- mode1 = 0x0001; /* MFM, 2HD, 256 */
- mode2 = 0x021a; /* 2Head, 26sector */
- ret = DKB_setmode(devno, mode1, mode2);
-
- cylno = 1; hedno = 0; secno = 1; seccnt = 2;
- ercnt = 0;
- while(1) {
- ret = DKB_restore(devno);
- if (DKB_read( devno, cylno, hedno, secno, seccnt, headblk, &secnum) == 0) break;
- { int i; for (i = 0; i < 30000; i++); }
- if (++ercnt > 9) { drverr(drv); return(-1); }
- }
- if (headblkpri(headblk, drv) == -1) { return(-1); }
- if (vol == 0) return(0);
- } while (atoi(strmid(msg, headblk, 221, 4)) != vol);
- return(0);
- }
-
-
- int dataset3(int drv, int warea)
- {
- int mx, my, wx, wy, wi;
- int cx = 400, cy = 200;
- char msg1[80];
- char msg2[80];
- int x, y, devno, ret;
- unsigned mode1, mode2;
- int cylno, hedno, secno, seccnt;
- unsigned char headblk[2][512], wblk[512];
- int secnum;
- char wname[64];
- FILE *fp;
- char wwS[80], wS[80], wS2[80], satS[10], sensorS[10];
- char fmatS[5], bndtblS[10];
- int nch, nvol, vol;
- int i, j, ercnt;
- double wdf;
- size_t bsize, bn;
- int ys, ye, v, linst,linest, s;
- int trk, sid, sct, ch;
-
- sprintf(wname, "%s\\warea%1d.lnd", workdir, warea);
- linest = 1;
- x = 60; y = 65;
-
- if (volchg( 0, drv, headblk[1]) == -1) return(-1); /* no select volume */
-
- strmid(wS, headblk[1], 140, 1);
- if (strcmp(wS, "M") == 0) { strcpy(satS, "LANDSAT"); strcpy(sensorS, "MSS"); }
- if (strcmp(wS, "T") == 0) { strcpy(satS, "LANDSAT"); strcpy(sensorS, "TM"); }
- if (strcmp(wS, "E") == 0) { strcpy(satS, "MOS"); strcpy(sensorS, "MESSR"); }
- if (strcmp(wS, "V") == 0) { strcpy(satS, "MOS"); strcpy(sensorS, "VTIR"); }
-
- strmid( fmatS, headblk[1], 34, 3);
- nch = atoi(strmid( wS, headblk[1], 37, 4));
- strmid( bndtblS, headblk[1], 142, 7);
- nvol = atoi(strmid(wS, headblk[1], 217, 4)); if (nvol == 0) nvol = 1;
- vol = atoi(strmid(wS, headblk[1], 221, 4)); if (vol == 0) vol = 1;
-
- helpcls( 80, 230, 560, 300);
- sprintf( msg1, "バンド番号を下から選択して下さい。");
- msgset(96, 255, msg1, col0);
-
- sprintf(msg2, "%c %c %c %c %c %c %c", bndtblS[0], bndtblS[1], bndtblS[2], bndtblS[3], bndtblS[4], bndtblS[5], bndtblS[6]);
- msgset(96, 275, msg2, col12);
- wx = 435, wy = 275;
- recogmsg(wx, wy, col0); escmsg(wx+40, wy, col0);
- ch = 0; j = 0;
- while(1) {
- while((MOS_rdpos(&mx, &my) & 0x01) == 0);
- wy = 275;
- for (i = 0; i < 7; i++) {
- wx = 96+16*i;
- if ((xychk(mx, my, wx, wy, wx+8, wy+16) == 1) && (bndtblS[i] != ' ')) {
- line(96+16*j-1, wy-1, 96+16*j+9, wy+17, PSET, col7, 1, 0xffff);
- line(wx-1, wy-1, wx+9, wy+17, PSET, col14, 1, 0xffff);
- ch = bndtblS[i] - '0'; j = i;
- }
- }
- wx = 435, wy = 275;
- wi = recogin2( mx, my, wx, wy, 1);
- if (wi == -1) return(-1);
- if (wi == 1) {
- if (ch != 0) break;
- recogmsg(wx, wy, col0);
- }
- while((MOS_rdpos(&mx, &my) & 0x01) == 1);
- }
-
- /* start */
- ys = 0; ye = 399;
- v = vol;
-
- if (strcmp(sensorS, "VTIR") == 0) {
- helpcls( 80, 230, 560, 300);
- msgset(96, 255, "LANDSAT/MOS データの読み取り開始ラインを入力して下さい。", col0);
- msgset(96, 275, "[ 1 ~ 801 ]", col0);
- msgset(112, 275, "1", col13);
- if (recogin( 435, 275, 1) != 0) return(-1);
- wx = 435, wy = 275;
- recogmsg(wx, wy, col0); escmsg(wx+40, wy, col0);
- linst = 1; j = 0;
- while(1) {
- while((MOS_rdpos(&mx, &my) & 0x01) == 0);
- wx = 112;
- if (xychk(mx, my, wx, wy, wx+32, wy+16) == 1) {
- line(wx-1, wy-1, wy+9, wy+17, PSET, col14, 1, 0xffff);
- wdf = linst;
- if (calc( &cx, &cy, &wdf) != 0) {
- if (wdf < 1) linst = 1;
- else if (wdf > 801) linst = 801;
- else linst = wdf;
- linest = linst;
- }
- line(wx-1, wy-1, wx+9, wy+17, PSET, col7, 2, 0xffff);
- sprintf(msg2, "%d", linst);
- msgset(112, 275, msg2, col13);
- }
- wx = 435, wy = 275;
- wy = recogin2( mx, my, wx, wy, 1);
- if (wy == -1) return(-1);
- if (wy == 1) break;
- while((MOS_rdpos(&mx, &my) & 0x01) == 1);
- }
-
- if (strcmp(fmatS, "BSQ") == 0) {
- vol = ch; j = linst*2+1;
- } else {
- vol = (linst-1)/400+1;
- linst = linst - (vol-1)*400;
- ye = 400-linst;
- j = (linst-1)*nch*2 + ch*2 + 1;
- }
- trk = (j-1) / 52 + 1;
- j = j - (j / 52) * 52;
- if (j > 26) {
- sid = 1; sct = j - 26;
- } else {
- sid = 0; sct = j;
- }
- if (vol != v) {
- if (volchg(vol, drv, headblk[1]) == -1) return(-1);
- }
- }
-
- if (strcmp(fmatS, "BSQ") == 0) {
- sct = 3;
- switch (ch) {
- case 1: trk = 1; sid = 0; vol = 1; break;
- case 2: trk = 16; sid = 1; vol = 1; break;
- case 3: trk = 32; sid = 0; vol = 1; break;
- case 4: trk = 47; sid = 1; vol = 1; break;
- case 5: trk = 1; sid = 0; vol = 2; break;
- case 6: trk = 16; sid = 1; vol = 2; break;
- default: trk = 32; sid = 0; vol = 2; break;
- }
- if (v != vol) {
- if (volchg(vol, drv, headblk[1]) == -1) return(-1);
- }
- } else {
- trk = 1; sid = 0; sct = ch*2 + 1;
- if (nvol == 2) ye = 199;
- if (vol != 1) {
- vol = 1;
- if (volchg(vol, drv, headblk[1]) == -1) return(-1);
- }
- }
-
- /* work area open */
- if ((fp = fopen(wname, "w+b")) == NULL) {
- wareaerr(warea);
- return(-1);
- }
-
- helpcls( 80, 230, 560, 300);
- sprintf( msg2, "バンド %d のデータを読み込み中です。", ch);
- msgset(96, 255, msg2, col0);
- sprintf( msg2, "ドライブ %d → 作業領域 %d", drv, warea);
- msgset(96, 275, msg2, col0);
-
- /* header write */
- for ( i = 1; i <= 512; i++) headblk[0][i-1] = ' ';
- sprintf( headblk[0], "WORK.AREA ORIGINAL BAND.%3d LINEST.%4d", ch, linest);
- /* 123456789012345612345678901234561234567890123456 */
- bsize = 512; bn = 1;
- if (fwrite( headblk[0], bsize, bn, fp) != bn) {
- fclose(fp); wareaerr(warea); return(-1);
- }
- if (fwrite( headblk[1], bsize, bn, fp) != bn) {
- fclose(fp); wareaerr(warea); return(-1);
- }
-
- /* mos-1/landsat ---> work area */
- /* sct = sid * 26 + sct; */
- devno = 0x0020 | drv; /* 1MB floppy */
- bsize = 512; bn = 1; seccnt = 2;
-
- s = nch * 2;
- while (1) {
- for (i = ys; i <= ye; i++) {
- ercnt = 0;
- while(1) {
- if (DKB_read( devno, trk, sid, sct, seccnt, wblk, &secnum) == 0) break;
- { int i; for (i = 0; i < 30000; i++); }
- if (++ercnt > 9) { fclose(fp); drverr(drv); return(-1); }
- }
- if (fwrite( wblk, bsize, bn, fp) != bn) {
- fclose(fp); wareaerr(warea); return(-1);
- }
- sct = sct + s;
- if (sct > 26) {
- sct = sct - 26;
- if (sid == 0) sid = 1;
- else { sid = 0; trk = trk + 1; }
- }
- }
- if (ye == 399) break;
- vol = vol + 1;
- if (volchg( vol, drv, headblk[1]) == -1) { fclose(fp); return(-1); }
- ys = ye + 1; ye = 399;
- trk = 1; sid = 0; sct = ch * 2 + 1;
- }
- fclose(fp);
- return(0);
- }
-
-
- void dataset2(int drv, int warea)
- {
- unsigned ddadr[2];
- unsigned char page;
- char buf[30175]; /* (397*152+7)/8*4 */
- int x, y;
- int mx, my;
-
- x = 60; y = 65;
- page = 0;
- BSETDATAADR(ddadr, buf);
- GDS_getBlock(ddadr[0], ddadr[1], page, x, y, x+396, y+151);
-
- helpbox( x, y, x+390, y+120, "MOS-1/LANDSAT データ・ディスク内容");
- if (dataset3( drv, warea) != 0) {
- GDS_putBlock(ddadr[0], ddadr[1], page, x, y, x+396, y+151, PSET);
- return;
- }
- helpcls( 80, 230, 560, 300);
- msgset(96, 255, "正常に終了しました。", col0);
- msgset(96, 275, "確認ボタンを押してください。", col0);
- recogin( 435, 275, 0);
- GDS_putBlock(ddadr[0], ddadr[1], page, x, y, x+396, y+151, PSET);
- return;
- }
-
- void dataset( int datadrive)
- {
- int bcl[16];
- int exec, com, com2, com3, com4;
- int mx, my, mosx=400, mosy=100;
- unsigned char page;
-
- page = 1;
- GDS_displayPage(page);
- gout();
- page = 0;
- GDS_writePage(page);
- gout();
- menubox( 80, 40, 560, 220, "データ読み込み(観測衛星画像データ → 作業領域)");
- helpbox( 80,230, 560, 300, "メッセージ");
-
- msgset( 80, 70, " ○ ドライブ0", col0);
- msgset( 80, 90, " ○ ドライブ1", col0);
- msgset( 80,110, " ○ ドライブ2", col0);
- msgset( 80,130, " ○ ドライブ3", col0);
- msgset(320, 70, " ○ 作業領域1", col0);
- msgset(320, 90, " ○ 作業領域2", col0);
- msgset(320,110, " ○ 作業領域3", col0);
- migiya(240, 90-4, col0);
- msgset( 80,170, " ○ 終 了", col0);
- execmsg(480, 190, col0);
- calcu(600, 30, 0);
-
- GDS_displayPage(page);
- gout();
- locate(0,0,COFF);
- MOS_disp(0);
- exec = 0;
- com = com2 = datadrive + 1;
- com3 = com4 = 7;
-
- while(1) {
- if (com == 1) msgset( 96, 70, "●", col0);
- if (com == 2) msgset( 96, 90, "●", col0);
- if (com == 3) msgset( 96,110, "●", col0);
- if (com == 4) msgset( 96,130, "●", col0);
- if (com == 6) msgset( 96,170, "●", col0);
- if (com3 == 7) msgset(336, 70, "●", col0);
- if (com3 == 8) msgset(336, 90, "●", col0);
- if (com3 == 9) msgset(336,110, "●", col0);
- dsetmsg(com, 1);
-
- if (exec == 1) {
- if (1 <= com && com <= 4) {
- dataset2(com-1, com3-6);
- execmsg(480, 190, col0);
- helpcls( 80,230, 560, 300);
- exec = 0;
- continue;
- }
- if (com == 6) { return; }
- }
- while ((MOS_rdpos(&mx, &my) & 0x01) == 0);
- if (calchk(mx, my, 600, 30, &mosx, &mosy) == 1) continue;
- if (wabotchk(mx, my, 600, 60) == 1) continue;
-
- if (xychk16(mx, my, 96, 70) == 1) com = 1;
- if (xychk16(mx, my, 96, 90) == 1) com = 2;
- if (xychk16(mx, my, 96,110) == 1) com = 3;
- if (xychk16(mx, my, 96,130) == 1) com = 4;
- if (xychk16(mx, my, 96,170) == 1) com = 6;
- if (xychk16(mx, my,336, 70) == 1) com3 = 7;
- if (xychk16(mx, my,336, 90) == 1) com3 = 8;
- if (xychk16(mx, my,336,110) == 1) com3 = 9;
- if (xychk(mx, my,480,190, 480+33, 190+18) == 1) {
- execmsg(480, 190, -1);
- while ((MOS_rdpos(&mx, &my) & 0x01) == 1);
- if (xychk(mx, my,480,190, 480+33, 190+18) == 1) {
- exec = 1;
- continue;
- } else {
- exec = 0;
- execmsg(480, 190, col0);
- continue;
- }
- }
- if (com != com2) {
- if (com2 == 1) { msgset( 96, 70, "●", col7); msgset( 96, 70, "○", col0); }
- if (com2 == 2) { msgset( 96, 90, "●", col7); msgset( 96, 90, "○", col0); }
- if (com2 == 3) { msgset( 96,110, "●", col7); msgset( 96,110, "○", col0); }
- if (com2 == 4) { msgset( 96,130, "●", col7); msgset( 96,130, "○", col0); }
- if (com2 == 6) { msgset( 96,170, "●", col7); msgset( 96,170, "○", col0); }
- dsetmsg(com2, 0);
- com2 = com;
- }
- if (com3 != com4) {
- if (com4 == 7) { msgset(336, 70, "●", col7); msgset(336, 70, "○", col0); }
- if (com4 == 8) { msgset(336, 90, "●", col7); msgset(336, 90, "○", col0); }
- if (com4 == 9) { msgset(336,110, "●", col7); msgset(336,110, "○", col0); }
- com4 = com3;
- }
- }
- }
-
-
- void dsavemsg(int com, int com9, int sw)
- {
- char hmsg1[80], hmsg2[80];
- int col;
-
- hmsg1[0] = '\0'; hmsg2[0] = '\0';
-
- if (com == 1 || com == 2 || com == 3) {
- strcpy(hmsg1, "作業領域と退避・復帰(矢印部分)を選択してください。");
- strcpy(hmsg2, "MS-DOSのファイル名を設定ししてください。");
- }
-
- /*
- if (com == 1) {
- if (com9 == 0) strcpy(hmsg1, "作業領域1のデータを退避します。");
- else strcpy(hmsg1, "作業領域1のデータを復帰します。");
- strcpy(hmsg2, "MS-DOSのファイル名を設定ししてください。");
- }
-
- if (com == 2) {
- if (com9 == 0) strcpy(hmsg1, "作業領域2のデータを退避します。");
- else strcpy(hmsg1, "作業領域2のデータを復帰します。");
- strcpy(hmsg2, "MS-DOSのファイル名を設定ししてください。");
- }
-
- if (com == 3) {
- if (com9 == 0) strcpy(hmsg1, "作業領域3のデータを退避します。");
- else strcpy(hmsg1, "作業領域3のデータを復帰します。");
- strcpy(hmsg2, "MS-DOSのファイル名を設定ししてください。");
- }
- */
-
- if (com == 6) {
- strcpy(hmsg1, "メイン・メニューにもどります。");
- }
-
- if (com == 8) {
- strcpy(hmsg1, "ファイル名をキーボードで入力してください。");
- strcpy(hmsg2, "ファイル名は半角で8文字までです。");
- }
-
- if (sw == 0) col = col7;
- else col = col0;
-
- msgset(96, 255, hmsg1, col);
- msgset(96, 275, hmsg2, col);
- }
-
- void namin(char fnam[])
- {
- char dirnam[64], fname[13];
- int i;
- char strw[128];
-
- color(1, 0);
- dirnam[0] = 0; fname[0] = 0;
- helpbox( 320, 110, 580, 170, "ファイル名");
- sprintf(strw, "%s\n", fnam);
- symbol_( 328, 140, strw, 1,1, col0, 0 ,PSET);
- gfsel(240, 32, "ファイルの選択", dirnam, fname);
- if (strlen(dirnam) > 3) { /* ex A:\ */
- strcat(dirnam, "\\");
- }
- if (strlen(fname) == 0) fnam[0] = 0;
- else {
- strcat(dirnam, fname);
- strcpy(fnam, dirnam);
- }
- helpbox( 320, 110, 580, 170, "ファイル名");
- sprintf(strw, "%s\n", fnam);
- symbol_( 328, 140, strw, 1,1, col0, 0 ,PSET);
- /* msgset( 336, 144, fnam, col0); 16*21, 16*9 */
- /* qas(41, 9, "", fnam, 30); / * 8*41, 16*9 */
- }
-
- void dsaveerr( void)
- {
- unsigned ddadr[2];
- unsigned char page;
- char buf[30175]; /* (397*152+7)/8*4 */
- int x, y;
- int mx, my;
-
- x = 60; y = 65;
- page = 0;
- BSETDATAADR(ddadr, buf);
- GDS_getBlock(ddadr[0], ddadr[1], page, x, y, x+396, y+151);
-
- helpbox( x, y, x+390, y+120, "エラー");
- msgset(x+16, y+30, "エラーが発生しました。", col10);
-
- recogmsg(x+350, y+95, col0);
- while (1) {
- while ((MOS_rdpos(&mx, &my) & 0x01) == 0);
- if (xychk(mx, my, x+350, y+95, x+350+33, y+95+18) == 1) {
- recogmsg(x+350, y+95, -1);
- while((MOS_rdpos(&mx, &my) & 0x01) == 1);
- if (xychk(mx, my, x+350, y+95, x+350+33, y+95+18) == 0) {
- recogmsg(x+350, y+95, col0);
- continue;
- } else {
- break;
- }
- }
- }
- GDS_putBlock(ddadr[0], ddadr[1], page, x, y, x+396, y+151, PSET);
- return;
- }
-
- void datasave2(int warea, char fnam[])
- {
- char wstr[80];
-
- if (strlen(fnam) == 0) return;
- sprintf(wstr, "copy %s\\warea%1d.lnd %s", workdir, warea, fnam);
- if (system( wstr) == -1) dsaveerr();
- return;
- }
-
- void dataload2(int warea, char fnam[])
- {
- char wstr[80];
-
- if (strlen(fnam) == 0) return;
- sprintf(wstr, "copy %s %s\\warea%1d.lnd", fnam, workdir, warea);
- if (system( wstr) == -1) dsaveerr();
- return;
- }
-
- void dsmsgcls()
- {
- line(80+1, 230+21, 560-1, 300-1, PSET, col7, 2, 0xffff);
- }
-
- void datasave()
- {
- int bcl[16];
- int exec, com, com2, com3, com4, com9;
- int mx, my, mosx=400, mosy=100;
- unsigned char page;
- char fnam[64];
-
- fnam[0]='\0';
- /* strcpy(fnam, "SDFILE"); */
-
- page = 1;
- GDS_displayPage(page);
- gout();
- page = 0;
- GDS_writePage(page);
- gout();
- menubox( 80, 40, 560, 220, "作業領域の退避・復帰");
- helpbox( 80,230, 560, 300, "メッセージ");
-
- msgset( 80, 70, " ○ 作業領域1", col0);
- msgset( 80, 90, " ○ 作業領域2", col0);
- msgset( 80,110, " ○ 作業領域3", col0);
- msgset(320, 90, " ○ MS-DOS", col0);
- symbol_( 240+12, 90, "■", 3, 1, col0, 0, PSET);
- symbol_( 240+48, 90+23, "▼", 2, 1, col0, 1, PSET);
- symbol_( 240, 90+23, "▲", 2, 1, col8, 1, PSET);
- msgset( 80,170, " ○ 終 了", col0);
- execmsg(480, 190, col0);
- calcu(600, 30, 0);
-
- GDS_displayPage(page);
- gout();
- locate(0,0,COFF);
- MOS_disp(0);
- exec = 0;
- com = com2 = 1;
- com3 = com4 = 0;
- com9 = 0;
-
- while(1) {
- if (com3 == 8) {
- msgset(336, 90, "●", col0);
- dsmsgcls();
- dsavemsg(com3, com9, 1);
- namin(fnam);
- msgset(336, 90, "●", col7); msgset(336, 90, "○", col0);
- dsmsgcls();
- dsavemsg(com2, com9, 1);
- com3 = 0;
- } else {
- dsmsgcls();
- if (com == 1) msgset( 96, 70, "●", col0);
- if (com == 2) msgset( 96, 90, "●", col0);
- if (com == 3) msgset( 96,110, "●", col0);
- if (com == 6) msgset( 96,170, "●", col0);
- dsavemsg(com, com9, 1);
- }
- while ((MOS_rdpos(&mx, &my) & 0x01) == 1);
- if (exec == 1) {
- if (com9 == 0 && 1 <= com && com <= 3) { datasave2(com, fnam); }
- if (com9 == 1 && 1 <= com && com <= 3) { dataload2(com, fnam); }
- if (com == 6) { return; }
- exec = 0;
- execmsg(480, 190, col0);
- }
- while ((MOS_rdpos(&mx, &my) & 0x01) == 0);
- if (calchk(mx, my, 600, 30, &mosx, &mosy) == 1) continue;
- if (wabotchk(mx, my, 600, 60) == 1) continue;
-
- if (xychk16(mx, my, 96, 70) == 1) com = 1;
- if (xychk16(mx, my, 96, 90) == 1) com = 2;
- if (xychk16(mx, my, 96,110) == 1) com = 3;
- if (xychk16(mx, my, 96,170) == 1) com = 6;
- if (xychk16(mx, my,336, 90) == 1) com3 = 8;
- if (xychk(mx, my,480,190, 480+33, 190+18) == 1) {
- execmsg(480, 190, -1);
- while ((MOS_rdpos(&mx, &my) & 0x01) == 1);
- if (xychk(mx, my,480,190, 480+33, 190+18) == 1) {
- exec = 1;
- continue;
- } else {
- exec = 0;
- execmsg(480, 190, col0);
- continue;
- }
- }
- if (xychk( mx, my, 240+48, 90+23-32, 240+64, 90+23) == 1) {
- symbol_( 240+48, 90+23, "▼", 2, 1, col0, 1, PSET);
- symbol_( 240, 90+23, "▲", 2, 1, col8, 1, PSET);
- com9 = 0;
- continue;
- }
- if (xychk( mx, my, 240, 90+23-32, 240+16, 90+23) == 1) {
- symbol_( 240+48, 90+23, "▼", 2, 1, col8, 1, PSET);
- symbol_( 240, 90+23, "▲", 2, 1, col0, 1, PSET);
- com9 = 1;
- continue;
- }
- if (com != com2) {
- if (com2 == 1) { msgset( 96, 70, "●", col7); msgset( 96, 70, "○", col0); }
- if (com2 == 2) { msgset( 96, 90, "●", col7); msgset( 96, 90, "○", col0); }
- if (com2 == 3) { msgset( 96,110, "●", col7); msgset( 96,110, "○", col0); }
- if (com2 == 6) { msgset( 96,170, "●", col7); msgset( 96,170, "○", col0); }
- com2 = com;
- }
- }
- }
-
-